//
//  LSNewsTableViewMultipleImageCell.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2018/12/26.
//  Copyright © 2018 wpkj. All rights reserved.
//

#import "LSNewsTableViewMultipleImageCell.h"
#import "LSNewsViewModel.h"

@interface LSNewsTableViewMultipleImageCell ()
@property (nonatomic, strong) UILabel *mainTitleLabel;
@property (nonatomic, strong) UILabel *addressAndTimeLabel;
@property (nonatomic, strong) UIImageView *mainFirstImageView;
@property (nonatomic, strong) UIImageView *mainSecondImageView;
@property (nonatomic, strong) UIImageView *mainThirdImageView;
@end

@implementation LSNewsTableViewMultipleImageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView addSubview:self.mainTitleLabel];
        [self.contentView addSubview:self.addressAndTimeLabel];
        [self.contentView addSubview:self.mainFirstImageView];
        [self.contentView addSubview:self.mainSecondImageView];
        [self.contentView addSubview:self.mainThirdImageView];
    }
    return self;
}

- (void)setModel:(LSNewsViewModel *)model {
    _model = model;
//    self.mainTitleLabel.text = model.title;
//    self.addressAndTimeLabel.text = [NSString stringWithFormat:@"%@        %@",model.origin,model.releaseDate];
//    if (model.typeImg.count == 2) {
//        self.mainFirstImageView.image = [UIImage imageNamed:model.typeImg.firstObject];
//        self.mainSecondImageView.image = [UIImage imageNamed:model.typeImg[1]];
//        self.mainThirdImageView.image = nil;
//        self.mainThirdImageView.hidden = true;
//    } else {
//        self.mainFirstImageView.image = [UIImage imageNamed:model.typeImg.firstObject];
//        self.mainSecondImageView.image = [UIImage imageNamed:model.typeImg[1]];
//        self.mainThirdImageView.image = [UIImage imageNamed:model.typeImg.lastObject];
//        self.mainThirdImageView.hidden = false;
//    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    WS
    [self.mainTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(15);
        make.top.equalTo(weakSelf.contentView.mas_top).with.offset(15);
        make.right.equalTo(weakSelf.contentView.mas_right).with.offset(-15);
    }];
    [self.mainFirstImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(LSNewsTableViewMultipleImageCellImageMargin);
        make.top.equalTo(weakSelf.contentView.mas_top).with.offset(40);
        make.size.mas_equalTo(CGSizeMake((ScreenWidth-LSNewsTableViewMultipleImageCellImageMargin*4)/3, (ScreenWidth-LSNewsTableViewMultipleImageCellImageMargin*4)/3));
    }];
    [self.mainSecondImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(LSNewsTableViewMultipleImageCellImageMargin*2+(ScreenWidth-LSNewsTableViewMultipleImageCellImageMargin*4)/3);
        make.top.equalTo(weakSelf.contentView.mas_top).with.offset(40);
        make.size.mas_equalTo(CGSizeMake((ScreenWidth-LSNewsTableViewMultipleImageCellImageMargin*4)/3, (ScreenWidth-LSNewsTableViewMultipleImageCellImageMargin*4)/3));
    }];
    [self.mainThirdImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(LSNewsTableViewMultipleImageCellImageMargin*3+(ScreenWidth-LSNewsTableViewMultipleImageCellImageMargin*4)/3*2);
        make.top.equalTo(weakSelf.contentView.mas_top).with.offset(40);
        make.size.mas_equalTo(CGSizeMake((ScreenWidth-LSNewsTableViewMultipleImageCellImageMargin*4)/3, (ScreenWidth-LSNewsTableViewMultipleImageCellImageMargin*4)/3));
    }];
    [self.addressAndTimeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(15);
        make.bottom.equalTo(weakSelf.contentView.mas_bottom).with.offset(-8);
        make.right.equalTo(weakSelf.contentView.mas_right).with.offset(-15);
    }];
}

- (UILabel *)mainTitleLabel {
    if (!_mainTitleLabel) {
        _mainTitleLabel = [[UILabel alloc] init];
        _mainTitleLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:14];
        _mainTitleLabel.textColor = hexColor(333333);
    }
    return _mainTitleLabel;
}

- (UILabel *)addressAndTimeLabel {
    if (!_addressAndTimeLabel) {
        _addressAndTimeLabel = [[UILabel alloc] init];
        _addressAndTimeLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:10];
        _addressAndTimeLabel.textColor = hexColor(999999);
    }
    return _addressAndTimeLabel;
}

- (UIImageView *)mainFirstImageView {
    if (!_mainFirstImageView) {
        _mainFirstImageView = [[UIImageView alloc] init];
    }
    return _mainFirstImageView;
}

- (UIImageView *)mainSecondImageView {
    if (!_mainSecondImageView) {
        _mainSecondImageView = [[UIImageView alloc] init];
    }
    return _mainSecondImageView;
}

- (UIImageView *)mainThirdImageView {
    if (!_mainThirdImageView) {
        _mainThirdImageView = [[UIImageView alloc] init];
    }
    return _mainThirdImageView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
